package com.atguigu.tingshu.order.interceptor.impl;

import com.alibaba.fastjson.JSON;
import com.atguigu.tingshu.common.constant.SystemConstant;
import com.atguigu.tingshu.order.helper.SignHelper;
import com.atguigu.tingshu.order.interceptor.OrderHandlerInterceptor;
import com.atguigu.tingshu.vo.order.OrderInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.Objects;

/**
 * Author  王东剑
 * Created on 23/6/2024 PM12:27
 * Package_name com.atguigu.tingshu.order.interceptor.impl
 * Description
 */
@Service
@Slf4j
public class ValidDataOrderHandlerInterceptor implements OrderHandlerInterceptor {
	@Override
	public OrderInfoVo submitOrderRequestProcess(OrderInfoVo orderInfoVo) {
		log.info("ValidDataOrderHandlerInterceptor.submitOrderRequestProcess");
		Map<String, Object> orderInfoVoMap = JSON.parseObject(JSON.toJSONString(orderInfoVo), Map.class);
		orderInfoVoMap.put("payWay", SystemConstant.ORDER_PAY_WAY_WEIXIN);
		SignHelper.checkSign(orderInfoVoMap);
		log.info("验签通过.............");
		return orderInfoVo;
	}

	@Override
	public int sort() {
		return 1;
	}
}
